//
//  LSZBasicInformationCollectionViewCell.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/8/21.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZBasicInformationCollectionViewCell.h"

@implementation LSZBasicInformationCollectionViewCell
-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        UIView * viewTop = [[UIView alloc]initWithFrame:CGRectMake(10, 0, ScreenWidth-20, 0.5)];
        viewTop.backgroundColor = divider;
        [self addSubview:viewTop];

        self.imageHeader = [[UIImageView alloc]init];
        [self.imageHeader.layer setMasksToBounds:YES];
        [self addSubview:self.imageHeader];

        self.labelName = [[UILabel alloc]init];
        self.labelName.textColor = titleColorLSZ;
        [LSZSpecialPackaging setLabelAdaptiveSize:self.labelName font:16];
        [self addSubview:self.labelName];

        self.labelTime = [[UILabel alloc]init];
        self.labelTime.textColor = lightColor;
        [LSZSpecialPackaging setLabelAdaptiveSize:self.labelTime font:13];
        [self addSubview:self.labelTime];

        self.butFocusOn = [[UIButton alloc]init];
        self.butFocusOn.backgroundColor = redUIColor;
        [self.butFocusOn.layer setMasksToBounds:YES];
        [self.butFocusOn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [self.butFocusOn setTitle:@"+关注" forState:UIControlStateNormal];
        [self addSubview:self.butFocusOn];

        self.labelTitle = [[UILabel alloc]init];
//        [self.labelTitle debug:arc4random_color width:1];
        self.labelTitle.textColor = titleColorLSZ;
        self.labelTitle.alpha = 0.8;
        self.labelTitle.numberOfLines = 0;
        [LSZSpecialPackaging setLabelAdaptiveSize:self.labelTitle font:15];
        [self addSubview:self.labelTitle];

        CGFloat sizeImage = [LSZSpecialPackaging initWithReturnsthesizeOf:45 :5];
        self.imageHeader.frame = CGRectMake(10, 15, sizeImage, sizeImage);
        [LSZSpecialPackaging setLabelAdaptiveSize:self.butFocusOn.titleLabel font:13.5];
        CGFloat heightLabel = [LSZSpecialPackaging initWithReturnsthesizeOf:22 :2];
        self.labelName.frame = CGRectMake(CGRectGetMaxX(self.imageHeader.frame)+5, CGRectGetMinY(self.imageHeader.frame), ScreenWidth-CGRectGetMaxX(self.imageHeader.frame)-90, heightLabel);
        self.labelTime.frame = CGRectMake(CGRectGetMaxX(self.imageHeader.frame)+5, CGRectGetMaxY(self.imageHeader.frame)-20, self.labelName.frame.size.width, heightLabel);
        CGFloat sizeButFocusOn = [LSZSpecialPackaging initWithReturnsthesizeOf:55 :5];
        CGFloat heightButFocusOn = [LSZSpecialPackaging initWithReturnsthesizeOf:30 :5];
        self.butFocusOn.frame = CGRectMake(ScreenWidth-sizeButFocusOn-10, CGRectGetMinY(self.imageHeader.frame), sizeButFocusOn, heightButFocusOn);
        self.labelTitle.frame = CGRectMake(CGRectGetMaxX(self.imageHeader.frame)+5, CGRectGetMaxY(self.imageHeader.frame)+heightLabel-10, ScreenWidth-15-CGRectGetMaxX(self.imageHeader.frame), 40);
        [self.imageHeader.layer setCornerRadius:self.imageHeader.frame.size.height/2];
        [self.butFocusOn.layer setCornerRadius:4];
    }
    return self;
}
-(void)setAllDynamicListsMg:(LSZAllDynamicListsMg *)AllDynamicListsMg
{
    [self.imageHeader sd_setImageWithURL:[NSURL URLWithString:AllDynamicListsMg.avatar] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    if([AllDynamicListsMg.is_follow isEqualToString:@"0"]){
        self.butFocusOn.backgroundColor = redUIColor;
        [self.butFocusOn setTitle:@"+关注" forState:UIControlStateNormal];
        self.butFocusOn.userInteractionEnabled = YES;
    }else if ([AllDynamicListsMg.is_follow isEqualToString:@"2"]){
        self.butFocusOn.hidden = YES;
    }
    else{
        [self.butFocusOn setTitle:@"已关注" forState:UIControlStateNormal];
        self.butFocusOn.backgroundColor =  partialShallow;
        self.butFocusOn.userInteractionEnabled = NO;
    }
    self.labelName.text = AllDynamicListsMg.username;
    self.labelTime.text = [NSString stringWithFormat:@"%@  %@",AllDynamicListsMg.city,AllDynamicListsMg.add_time];
    NSString * string = [NSString stringWithFormat:@"%@%@",AllDynamicListsMg.theme_content,AllDynamicListsMg.content];
    self.labelTitle.text = string;
    CGFloat A = [LSZSpecialPackaging initWithReturnsthesizeOf:13.5 :0.5];
    CGFloat sizeImage = [LSZSpecialPackaging initWithReturnsthesizeOf:45 :5];
    CGFloat height = [LSZSpecialPackaging caculateHeightOfText:ScreenWidth-25-sizeImage height:80 font:A :string];
    CGRect rect = self.labelTitle.frame;
    rect.size.height = height-10;
    self.labelTitle.frame = rect;
}
@end
